const { Activity, ActivityParticipant } = require('./models');

async function debugActivities() {
  try {
    console.log('=== 检查所有活动 ===');
    const activities = await Activity.findAll();
    activities.forEach(a => {
      console.log(`ID: ${a.id}, 标题: ${a.title}, 状态: ${a.status}, 创建者: ${a.created_by}, 参与人数: ${a.current_participants}/${a.max_participants}`);
    });

    console.log('\n=== 检查活动ID为2的详细信息 ===');
    const activity2 = await Activity.findByPk(2);
    if (activity2) {
      console.log('活动2详情:', {
        id: activity2.id,
        title: activity2.title,
        status: activity2.status,
        created_by: activity2.created_by,
        start_time: activity2.start_time,
        end_time: activity2.end_time,
        current_participants: activity2.current_participants,
        max_participants: activity2.max_participants
      });

      // 检查参与者
      const participants = await ActivityParticipant.findAll({
        where: { activity_id: 2 }
      });
      console.log('当前参与者数量:', participants.length);
      participants.forEach(p => {
        console.log(`  用户${p.user_id} - 状态: ${p.status}`);
      });
    } else {
      console.log('活动ID为2的活动不存在');
    }

    process.exit(0);
  } catch (error) {
    console.error('调试失败:', error);
    process.exit(1);
  }
}

debugActivities(); 